import requests
  
def checkip(ip):
  
  URL = 'http://ip.taobao.com/service/getIpInfo.php'
  try:
    r = requests.get(URL, params=ip, timeout=3)
  except requests.RequestException as e:
    print(e)
  else:
    json_data = r.json()
    if json_data[u'code'] == 0:
      print 'country： ' + json_data[u'data'][u'country'].encode('utf-8')
      print '11： ' + json_data[u'data'][u'area'].encode('utf-8')
      print 'dd： ' + json_data[u'data'][u'region'].encode('utf-8')
      print 'cc： ' + json_data[u'data'][u'city'].encode('utf-8')
      print 'ff：' + json_data[u'data'][u'isp'].encode('utf-8')
    else:
      print 'ff！'
  
ip={'ip': '202.102.193.68'}
checkip(ip)